export const switchTier: Record<string, string> = {
  IRON: "无畏黑铁",
  BRONZE: "英勇黄铜",
  SILVER: "不屈白银",
  GOLD: "荣耀黄金",
  PLATINUM: "华贵铂金",
  EMERALD: "流光翡翠",
  DIAMOND: "璀璨钻石",
  MASTER: "超凡大师",
  GRANDMASTER: "傲世宗师",
  CHALLENGER: "最强王者",
  NONE: "未定级",
};
export class RankStatus {
  name: string;
  rankIcon: string;
  rankTier: string;
  rankDivision: string;
  Lp: number;
  Win: number;
  Lose: number;
  winRate: number;
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  constructor(name: string, data: any) {
    if (data) {
      this.name = name;
      const tier = data.tier.toLowerCase();
      const icon = tier === "" ? "unranked" : tier;
      this.rankIcon = `https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-shared-components/global/default/${icon}.png`;
      this.rankTier = switchTier[data.tier || "NONE"];
      this.rankDivision = data.division === "NA" ? "" : data.division;
      this.Lp = data.leaguePoints;
      this.Win = data.wins;
      this.Lose = data.losses;
      this.winRate =
        data.wins + data.losses === 0
          ? 0
          : Math.floor((data.wins / (data.wins + data.losses)) * 100);
    } else {
      this.name = "";
      this.rankIcon = `https://raw.communitydragon.org/latest/plugins/rcp-fe-lol-shared-components/global/default/unranked.png`;
      this.rankTier = "";
      this.rankDivision = "";
      this.Lp = 0;
      this.Win = 0;
      this.Lose = 0;
      this.winRate = 0;
    }
  }
}
